package com.tensquare.friend.dao;


import com.tensquare.friend.pojo.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface FriendDao extends JpaRepository<Friend,String> {

    //1.查询是否存在该用户
    @Query(nativeQuery = true,value = "select count(*) from tb_friend where userid =?1 and friendid=?2")
    int selectCount(String userId, String friendId);

    //2.修改islike值
    @Modifying
    @Query(nativeQuery = true,value = "update tb_friend set islike=?3 where userid=?1 and friendid=?2")
    void updateIslike(String userId,String friendId,String islike);

    @Modifying
    @Query(nativeQuery = true,
    value = "delete from tb_friend where userid=?1 and friendid=?2")
    void deleteFriend(String id, String friendId);

}
